package utils;

import java.io.InputStream;
import java.util.Properties;

/**
 * @function 读取properties工具类
 * @author Team03 陈渤榆
 * @date 2022-06-08 9:42
 * @email chenboyu2002@qq.com
 */
public class PropertiesUtils {
    /**
     * 根据properties文件名和key值获取value
     * @param fileName
     * @param key
     * @return
     */
    public static String getPropertiesValue(String fileName,String key){
        Properties p = new Properties();
        String value = null;
        try {

            InputStream in = PropertiesUtils.class.getResourceAsStream(fileName);
            p.load(in);
            in.close();

            if(p.containsKey(key)){
                value = p.getProperty(key);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return value;
    }



}
